(function(vc){
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        propTypes: {
           emitChooseService:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseServiceInfo:{
                services:[],
                _currentServiceName:'',
                total: 0,
                records: 1,
                conditions:{}
            }
        },
        _initMethod:function(){
            vc.component._loadAllServiceInfo(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent:function(){
            vc.on('chooseService','openChooseServiceModel',function(_param){
                console.log("打开业主成员界面")
                $('#chooseServiceModel').modal('show');
                vc.component._refreshChooseServiceInfo();
                vc.component._loadAllServiceInfo(DEFAULT_PAGE,DEFAULT_ROWS,'');
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                vc.component._loadAllServiceInfo(_currentPage, DEFAULT_ROWS,vc.component.chooseServiceInfo._currentServiceName);
            });
        },
        methods:{
            _loadAllServiceInfo:function(_page,_row,_name){
                vc.component.chooseServiceInfo.conditions.page = _page;
                vc.component.chooseServiceInfo.conditions.row = _row;
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        /*communityId:vc.getCurrentCommunity().communityId,*/
                        name:_name
                    }
                };

                //发送get请求
               vc.http.get('chooseService',
                            'list',
                             param,
                             function(json){
                                var _serviceInfo = JSON.parse(json);
                                vc.component.chooseServiceInfo.services = _serviceInfo.services;
                                 vc.component.chooseServiceInfo.total = _serviceInfo.total;
                                 vc.component.chooseServiceInfo.records = _serviceInfo.records;
                                 vc.emit('pagination', 'init', {
                                     total: vc.component.chooseServiceInfo.records,
                                     currentPage: _page
                                 });
                                },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseService:function(_service){
                vc.emit($props.emitChooseService,'chooseService',_service);
                vc.emit($props.emitLoadData,'listServiceData',{
                    serviceId:_service.serviceId
                });
                $('#chooseServiceModel').modal('hide');
            },
            queryServices:function(){
                console.log("查询")
                vc.component._loadAllServiceInfo(DEFAULT_PAGE,DEFAULT_ROWS,vc.component.chooseServiceInfo._currentServiceName);
            },
            _refreshChooseServiceInfo:function(){
                vc.component.chooseServiceInfo._currentServiceName = "";
            }
        }

    });
})(window.vc);
